#pragma once 

#include "Containers/Optional.h"
#include "Containers/Map.h"
#include "Containers/Any.h"
#include "Type.h"

class WHENGINE_API CEnumBase: public CType
{

public:
    CEnumBase(TMap<int64_t /*Value */  ,CString /* Value name*/ > InValues
        ,STypeID InTypeID
        ,ETypeFlags InExtraFlags
        );

    //get type of enum value, for example, int32_t/uint32_t etc.
    virtual CType* GetValueType() const=0;

    bool IsValidValue(int64_t InValue)
    {
        return Values.Contains(InValue);
    }

    CString GetValueName(int64_t InValue)
    {
        return Values[InValue];
    }

    CString GetValueName(const CAny& InAny );

    int64_t GetValue(const CString& InName) const;

    TVector<CString> GetAllNames() const
    {
        return Values.Values();
    }

    TVector<int64_t> GetAllValues() const
    {
        return Values.Keys();
    }

protected:
    TMap<int64_t /*Value */  ,CString /* Value name*/ > Values;

    CString SerializeToString(const void* InInstance) const ;
    void DeserializeFromString(const CString& InString,void * InInstance) const ;
    friend class EnumStringSerializable;
};